<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
	  <title>Abraham Lincoln's Gettysburg Address</title>

    <link rel="stylesheet" href="style/04.css" type="text/css" />
    <script src="js/jquery.js"></script>
    <script>
      $(function () {
        // 1.修改样式表，一开始先隐藏页面的内容，当页面加载后，慢慢淡入内容
        //隐藏段落内容
        $("#container").hide();
        $("#container").fadeIn("slow");
        // 2.在鼠标悬停在段落上面时，给段落应用黄色背景
        //hover可以有两个函数，一个移入，一个移除
        $("p").hover(function () {
            $(this).css("background","yellow");
        },function () {
            $(this).css("background","white");
        });

        // 3.单击标题<h2>使其不透明度变为25%，同时添加20px的右外边距，
        // 当这两个完成后，把讲话文本变为50%的不透明度
        $("h2").click(function () {
            $(this).animate({opacity:0.25,marginRight:20},200,function () {
              $(".speech").animate({opacity: 0.5});
            });
        });

        // 4.按下方向键时，使样式转换器向相应的方向平滑移动20像素，左37，上38，右39，下40
        let left=0,top=0;
        $(document).keyup(function (e) {
          switch(e.which){
              case 37: left=left-20;$("#switcher").animate({marginLeft: left});break;
              case 38: top=top-20;  $("#switcher").animate({marginTop: top});break;
              case 39: left=left+20;$("#switcher").animate({marginLeft: left});break;
              case 40: top=top+20; $("#switcher").animate({marginTop: top});break;
          }
        });

      })
    </script>
  </head>
  <body>
    <div id="container">
      <h2>Abraham Lincoln's Gettysburg Address</h2>
      <div id="switcher">
        <div class="label">Text Size</div>
        <button id="switcher-default">Default</button>
        <button id="switcher-large">Bigger</button>
        <button id="switcher-small">Smaller</button>
      </div>
      <div class="speech">
        <p>Fourscore and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.</p>
        <p>Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting-place for those who here gave their lives that the nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow, this ground.</p>
        <a href="#" class="more">read more</a>
        <p>The brave men, living and dead, who struggled here have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember, what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.</p>
        <p>It is rather for us to be here dedicated to the great task remaining before us&mdash;that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion&mdash;that we here highly resolve that these dead shall not have died in vain&mdash;that this nation, under God, shall have a new birth of freedom and that government of the people, by the people, for the people, shall not perish from the earth.</p>
      </div>
    </div>
  </body>
</html>
